import { Navigate } from 'react-router-dom';
import LoginView from '../views/LoginView/LoginView';
import HomeView from '../views/HomeView/HomeView';
import DashboardLayer from '../views/Dashboard/DashboardLayer';
import contentRoutes from './content';
import customerRoutes from './customer';
import dashboardRoutes from './dashboard';
import goodsRoutes from './goods';
import marketingRoutes from './marketing';
import orderRoutes from './order';
import systemRoutes from './system';
import financeRoutes from './finance';

const routes = [
  {
    path: '/',
    element: <Navigate to='/home' />,
  },
  {
    path: '/login',
    element: <LoginView />,
  },
  {
    path: '/home',
    breadcrumb: '首页',
    element: <HomeView />,
    children: [
      {
        path: '',
        // 如果用重定向存在问题：首页无法回退到登录页
        element: <DashboardLayer />,
      },
      ...contentRoutes,
      ...customerRoutes,
      ...dashboardRoutes,
      ...goodsRoutes,
      ...marketingRoutes,
      ...orderRoutes,
      ...systemRoutes,
      ...financeRoutes,
    ],
  },
  {
    path: '*',
    element: <h4>404</h4>,
  },
];
export default routes;
